
import { uploadData, getPosition, getStruct, pushRateToList, readExel } from '../batch'

module.exports = function (params) {

    let exel = getStruct(params.downloadUrl);
    let exelList = []

    console.log("批量录入了..........")

    readExel({
        lines: exel.lines,
        cols: exel.columns,
        table: exel.table,
        eachLine(arr) {

            var row = {}
            
            var nameList = [
                'name', 'age', 'insuredWay', 'renewalMethod', 'evGuarantee',
                'evGuaranteeScore', 'evService', 'evServiceScore', 'valueAddInsuranceInfo', 'valueAddInsuranceScore', 'carAccidentProbability',
                'carAccidentDescribe', 'publicTransportAccidentProbability', 'publicTransportAccidentDescribe', 'generalAccidentDescribe', 'termInsuranceDescribeProbability',
                'termInsuranceDescribe', 
                'crowdSuitsInfo',  
            // 'prePurchaseServiceId', 'insuranceCategoryId', 'isurerId'
            ];


            for (let i = 0; i < nameList.length; i++) {
                arr[i]&&(row[nameList[i]] = arr[i]);
            }

            
            exelList.push(row);

        }
    })

    return uploadData({
        url: "bath/pr-car-insurance",
        data: exelList,
        successData: {
            code:1
        },
        errData: {

        },
        token: params.token
    })
}